<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%><%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<tiles:insertDefinition name="layout">
	<tiles:putAttribute name="head">
		<style type="text/css">
.selected {
	visibility: hidden;
}
</style>
		<script type="text/javascript">
	    $(function() {
		$("#datepicker").datepicker({
		    showWeek : true,
		    firstDay : 1,
		    dateFormat : 'yy-mm-dd',
		    showOtherMonths : true,
		    selectOtherMonths : true,
		    onSelect : function(date, source) {
			$("form").submit();
		    }
		});

		$(".confirm").confirmDialog(function(data) {
		    helper.showMsg(data, {
			okHandler : function() {
			    location.reload();
			}
		    });
		});

		//$('.dropdown-toggle').dropdown();
	    });
	</script>
	</tiles:putAttribute>
	<tiles:putAttribute name="mainBody">
		<form class="form-horizontal">
			<fieldset>
				<legend>每日课程表</legend>
				<div class="control-group">
					<div class="control-label">日期选择</div>
					<div class="controls">
						<a href="?startDate=${preDate}" class="btn">
							<i class="icon-chevron-left"></i>
						</a>
						<input type="text" name="startDate" id="datepicker" value="${currentDate}" />
						<a href="?startDate=${nextDate}" class="btn">
							<i class="icon-chevron-right"></i>
						</a>
					</div>
				</div>
			</fieldset>
		</form>
		<ul class="nav nav-tabs">
			<li class="active"><a href="#morning" class="scroll">Morning</a></li>
			<li><a href="#afternoon" class="scroll">Afternoon</a></li>
			<li><a href="#evening" class="scroll">Evening</a></li>
		</ul>
		<table class="table">
			<thead>
				<tr>
					<th>Time</th>
					<th>Lesson</th>
					<th>Teacher</th>
					<th>Classroom</th>
					<th>Listeners</th>
					<th>Count</th>
				</tr>
			</thead>
			<tbody>
				<s:iterator value="reports" var="report">
					<tr class="${report.lesson.courseType.cssClass}">
						<td>${report.lesson.timespan}</td>
						<td><s:url action="listListener" namespace="/lesson" id="listListener">
								<s:param name="id" value="lesson.id"></s:param>
							</s:url> <a href="${listListener}">${lesson.name}</a> <s:if test="canceled">
								<span class="label">已取消</span>
							</s:if></td>
						<td><s:iterator value="lesson.teachings" var="teaching" status="status">
								${teaching.teacher.name}
								<s:if test="!status.last">,</s:if>
							</s:iterator></td>
						<td>${report.lesson.classroom.name}</td>
						<td><s:iterator value="orderLessonLogs" var="orderLessonLog">
								<div class="btn-group">
									<a class="btn dropdown-toggle" id="dLabel" role="button" data-toggle="dropdown" data-target="#" href="/page.html">
										<s:if test="#orderLessonLog.mark.toString() == 'Good'">
											<i class="icon-thumbs-up" title="Good"></i>
										</s:if>
										<s:elseif test="#orderLessonLog.mark.toString()== 'Bad'">
											<i class="icon-thumbs-down" title="Bad"></i>
										</s:elseif>
										<s:if test="#orderLessonLog.leaveEarly">
											<i class="icon-download" title="早退"></i>
		</s:if>
										<s:if test="#orderLessonLog.beLate">
											<i class="icon-time" title="迟到"></i>
		</s:if>
										<s:if test="!#orderLessonLog.valid">
											<span class="label">不统计课时</span>
										</s:if>
										${orderLessonLog.student.name}<b class="caret"></b>
									</a>
									<s:url action="doMarkGoodOrderLesson" namespace="/orderlesson" id="doMarkGoodOrderLesson">
										<s:param name="id" value="#orderLessonLog.id"></s:param>
									</s:url>
									<s:url action="doLateOrderLesson" namespace="/orderlesson" id="doLateOrderLesson">
										<s:param name="id" value="#orderLessonLog.id"></s:param>
									</s:url>
									<s:url action="doEarlyOrderLesson" namespace="/orderlesson" id="doEarlyOrderLesson">
										<s:param name="id" value="#orderLessonLog.id"></s:param>
									</s:url>
									<s:url action="doResetOrderLesson" namespace="/orderlesson" id="doResetOrderLesson">
										<s:param name="id" value="#orderLessonLog.id"></s:param>
									</s:url>
									<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
										<s:if test="!beLate">
											<li><a title="设置该学员为迟到" class="confirm" href="${doLateOrderLesson}">迟到</a></li>
										</s:if>
										<s:if test="!leaveEarly">
											<li><a title="设置该学员为早退" class="confirm" href="${doEarlyOrderLesson}">早退</a></li>
										</s:if>
										<li><a title="重置该次订课状态" class="confirm" href="${doResetOrderLesson}">重置</a></li>
										<li class="divider" />
										<s:if test="#orderLessonLog.valid">
											<s:url action="doUnValidOrderLesson" namespace="/orderlesson" id="doUnValidOrderLesson">
												<s:param name="id" value="#orderLessonLog.id"></s:param>
											</s:url>
											<li><a title="不统计课时" class="confirm" type="button" href="${doUnValidOrderLesson}">
													<i class="icon-minus"></i>不统计课时
												</a></li>
										</s:if>
										<s:else>
											<s:url action="doValidOrderLesson" namespace="/orderlesson" id="doValidOrderLesson">
												<s:param name="id" value="#orderLessonLog.id"></s:param>
											</s:url>
											<a title="计算课时" type="button" class="confirm" href="${doValidOrderLesson}">
												<i class="icon-plus"></i>统计课时
											</a>
										</s:else>
										<s:url action="doCancelOrderLesson" namespace="/orderlesson" id="doCancelOrderLesson">
											<s:param name="id" value="#orderLessonLog.id"></s:param>
										</s:url>
										<li><a title="撤销该次订课" type="button" class="confirm" href="${doCancelOrderLesson}">撤销</a></li>
									</ul>
								</div>
							</s:iterator></td>
						<td>${report.count}</td>
					</tr>
				</s:iterator>
			</tbody>
			<tfoot></tfoot>
		</table>
	</tiles:putAttribute>
</tiles:insertDefinition>